<?php
require_once "yxxdbconn.php";


$sql = 'select "营业总额" as name, SUM(ORDER_PRICE) AS value FROM tb_order WHERE PAY_TYPE=2 OR PAY_TYPE=1';

$query=$mysqli->query($sql);
$res=mysqli_fetch_array($query);



$sql2 = "SELECT '昨日营业额' AS NAME , sum(order_price) AS VALUE FROM tb_order WHERE FROM_UNIXTIME(ORDER_DATETIME,'%Y-%m-%d')=date_format(date_sub(now(),interval 1 day),'%Y-%m-%d') and ORDER_STATE=3 ";
$query2=$mysqli->query($sql2);
$res2=mysqli_fetch_array($query2);



$sql3 = "SELECT '今日营业额' AS NAME , sum(order_price) AS VALUE FROM tb_order WHERE FROM_UNIXTIME(ORDER_DATETIME,'%Y-%m-%d')=date_format(now(),'%Y-%m-%d')  and ORDER_STATE=3 ";
$query3=$mysqli->query($sql3);
$res3=mysqli_fetch_array($query3);


$jsonStr["all"] = number_format($res['value'],2);


$jsonStr["today"] = number_format($res2['VALUE'],2);

$jsonStr["yesterday"]  = number_format($res3['VALUE'],2);

mysqli_close($mysqli); 

echo jsonSuccess($jsonStr);
?>